package com.example.task1.ui.AllService.word;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.example.task1.R;
import com.example.task1.bean.WordHistoryListBean;
import com.example.task1.ui.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

public class WorHistoryAdapter extends BaseAdapter<WordHistoryListBean.RowsDTO> {

    private List<WordHistoryListBean.RowsDTO> data = new ArrayList<>();
    private TextView tvJobName;
    private TextView tvMoney;
    private TextView tvThe;
    private TextView tvPerson;
    private TextView tvTime;

    @Override
    protected void setData(List<WordHistoryListBean.RowsDTO> rows) {
        int size = data.size();
        data.addAll(rows);
        notifyItemInserted(size);
    }

    @Override
    protected int getLayout() {
        return R.layout.wordhistorylist;
    }

    @Override
    protected Context getContext() {
        return null;
    }

    @Override
    protected List<WordHistoryListBean.RowsDTO> getData() {
        return data;
    }

    @Override
    protected void onBind(myHolder holder, WordHistoryListBean.RowsDTO date) {
        tvJobName.setText(date.getPostName());
        tvMoney.setText(date.getMoney() + "K");
        tvPerson.setText("投递人：" + date.getUserName());
        tvTime.setText(date.getSatrTime());
        tvThe.setText(date.getCompanyName());
    }

    @Override
    protected void holder(View itemView) {
        initView(itemView);
    }

    private void initView(View itemView) {
        tvJobName = (TextView) itemView.findViewById(R.id.tv_jobName);
        tvMoney = (TextView) itemView.findViewById(R.id.tv_money);
        tvThe = (TextView) itemView.findViewById(R.id.tv_the);
        tvPerson = (TextView) itemView.findViewById(R.id.tv_person);
        tvTime = (TextView) itemView.findViewById(R.id.tv_time);
    }
}
